package com.demo.springbootjobcron.job;


import com.demo.springbootjobcron.job.process.TestProcess;
import lombok.extern.slf4j.Slf4j;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.quartz.QuartzJobBean;
import org.springframework.stereotype.Component;

/**
 * @author Hanson
 * @date 2022/9/7 10:28
 */
@Component
@Slf4j
public class TestJob extends QuartzJobBean {

    @Value("${vccp.QuartzConfig.flag.of.run.OTAUpgradeJob}")
    private Boolean flagOfRun;

    @Autowired
    private TestProcess testProcess;

    @Override
    protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
        log.info("OTAUpgradeJob begin! {}", context.getJobDetail().getKey());
        if (flagOfRun == false) {
            log.info("OTAUpgradeJob flagOfRun {} ,return ", flagOfRun);
            return;
        }
        // 业务  deviceSchedulerTaskProcess
        testProcess.process();

        log.info("OTAUpgradeJob end! {}", context.getJobDetail().getKey());
    }
}
